/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Screen;

import ClassFrame.InputKey;
import ClassFrame.Map;
import ClassFrame.Resource;
import GamePlay.CanvasGame;
import javax.microedition.lcdui.Graphics;
/**
 *
 * @author QuyetNM1
 */
public class Rule extends IScreen {
    private long startTime;
    private long currTime;

    public Rule(CanvasGame _canvas) {
        super(_canvas);
    }
    
    public void initComponents(){
        canvas.getResource().unLoadSound(Resource.SOUND_MENU);
        canvas.getResource().playSound(Resource.SOUND_PLAY, -1);
    }

    public void load_screen() {
        canvas.getResource().loadArray(Resource.ruleArrayImages);
    }

    public void un_load_screen() {
        canvas.getResource().unLoadArray(Resource.ruleArrayImages);
    }

    public void keyEvent(int keycode, int event) {
        switch(event){
            case InputKey.KEY_EVENT_DOWN:
                canvas.getMap().initRound(Map.round);
                if(Map.round != Map.ROUND2){
                    canvas.setScreen(new ChoosePiece(canvas));
                } else {
                    Game.idQuest = 0;
                    canvas.setScreen(new Game(canvas, canvas.getMap().getQuestionByID(Game.idQuest)));
                }
                
                
                if(Map.round == Map.ROUND3){
                    Game.time = 60;
                }
                break;
        }
    }

    public void pointerEvent(int x, int y, int event) {
        switch(event){
            case InputKey.POINTER_EVENT_DOWN:
                canvas.getMap().initRound(Map.round);
                if(Map.round != Map.ROUND2){
                    canvas.setScreen(new ChoosePiece(canvas));
                } else {
                    Game.idQuest = 0;
                    canvas.setScreen(new Game(canvas, canvas.getMap().getQuestionByID(Game.idQuest)));
                }
                
                
                if(Map.round == Map.ROUND3){
                    Game.time = 60;
                }
                break;
        }
    }

    public void update() {
    }

    public void paint(Graphics g) {
        canvas.getImage().drawImage(g, canvas, Resource.IMG_RULE1 + Map.round, 0, 0);
    }
}
